
function Lov(option){
	var dialog_info = {};
	dialog_info.title = '查询列表';
	current.type = option.type;
	dialog_info.current = current.type;
	dialog_info.yesbtn = '保存';
	saveOrUpdate(dialog_info,option);
	loadGrid(option);
}

function saveOrUpdate(dialog_info,option){
	new Dialog({
			target:'#'+dialog_info.current+"_dialogbox",
			width:800,
			height: 640,
			showYesBtn:true,
			showNoBtn:true,
			title: dialog_info.title,
			yesBtnText:dialog_info.yesbtn,
			noBtnText:'取消',
			yesFn:function(){goback(option.obj)},
			noFn:function(){}}).show();
}


function loadGrid(option){
	params.currentPage = currentPage;
	params.pageSize = pageSize;
	$.ajax({
		url: option.url,
		type:'post',
		data:params
	}).done(function(data){
		var result = data.bo;
		var pager = {};
		$("#"+option.table+"").datagrid({
			fitColumns:true,
			singleSelect:true,
			pagination:true,
			remoteSort:false,
			multiSort:true,
			loadMsg:"数据加载中，请稍后……",
			data:result.list,
			columns:[option.columns],
			      onSortColumn: function (sort, order) {
			    	  setPager(pager,result.total);
			      },
			 onSelect:option.onSelect
		});
		var pager = $("#"+option.table+"").datagrid().datagrid('getPager');	// get the pager of datagrid
		setPager(pager,result.total);
	});
}

function setPager(pager,total){
	pager.pagination({
		total:total,
		pageNumber:currentPage,
	    pageSize:defaultPageSize,
	    layout:['first','prev','links','next','last'],
	    onSelectPage:function(cpage, psize){
	    	currentPage=cpage;
	    	pageSize=psize;
	    	loadGrid(option);
		}
	});
}
